package com.my.serviceimpl;

import com.my.bean.FinancialDaily;
import com.my.bean.ResultPage;
import com.my.bean.SituationAnalysis;
import com.my.bean.VoPage;
import com.my.mapper.FinancialDailyMapper;
import com.my.service.FinancialDailyService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.my.util.SessionUtil;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 财务日报 服务实现类
 * </p>
 *
 * @author 冯政尚
 * @since 2018-10-29
 */
@Service
public class FinancialDailyServiceImpl extends ServiceImpl<FinancialDailyMapper, FinancialDaily> implements FinancialDailyService {

    //查询的是同一天的页面只显示一条数据
    @Override
    public ResultPage<FinancialDaily> selectMyPage(Map map, VoPage voPage, HttpSession session, Long areaid, boolean admin) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1)*voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        paramMap.put("userId", SessionUtil.getSessionUser(session).getId());
        List<FinancialDaily> list = baseMapper.selectMyPage(map,paramMap,areaid,admin);
        Integer count = baseMapper.countMyPage(map,paramMap,areaid,admin);
        ResultPage<FinancialDaily> resultPage=new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }



    //查询的是根据日期来查询今天一共有多少数据
    @Override
    public ResultPage<FinancialDaily> selectMyPage2(Map map, VoPage voPage, HttpSession session, Long areaid, boolean admin,String res) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1)*voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        paramMap.put("userId", SessionUtil.getSessionUser(session).getId());
        List<FinancialDaily> list = baseMapper.selectMyPage2(map,paramMap,areaid,admin,res);
        Integer count = baseMapper.countMyPage2(map,paramMap,areaid,admin,res);
        ResultPage<FinancialDaily> resultPage=new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }

}
